import api from './index'
import { axios } from '@/utils/request'

// umsPermissionUrl: '/api-ums/ums/umsPermission/'

/**
 * 路由
 * // ums
    {
        path: '/ums',
        name: 'ums',
        component: PageView,
        redirect: '/ums/umsPermission',
        meta: { title: '后台用户权限表', icon: 'table', permission: [ 'ums' ] },
        children: [
          {
            path: '/ums/umsPermission',
            name: 'UmsPermission',
            component: () => import('@/views/ums/UmsPermissionList'),
            meta: { title: '后台用户权限表', keepAlive: true, permission: [ 'ums_umsPermission' ] }
          }
        ]
      },
 */

/**
 * 查询列表
 * @returns {*}
 */
export function getList (parameter) {
    return axios({
        url: api.umsPermissionUrl,
        method: 'get',
        data: parameter
    })
}

/**
 * 查询详情
 * @param id
 * @returns {*}
 */
export function getUmsPermission (id) {
    return axios({
        url: api.umsPermissionUrl + id,
        method: 'get'
    })
}

/**
 * 更新
 * @param id
 * @param parameter
 * @returns {*}
 */
export function updateUmsPermission (id, parameter) {
    return axios({
        url: api.umsPermissionUrl + id,
        method: 'post',
        data: parameter
    })
}

/**
 * 新增
 * @param parameter
 * @returns {*}
 */
export function addUmsPermission (parameter) {
    return axios({
        url: api.umsPermissionUrl,
        method: 'put',
        data: parameter
    })
}

/**
 * 删除
 * @param id
 * @returns {*}
 */
export function deleteUmsPermission (id) {
    return axios({
        url: api.umsPermissionUrl + id,
        method: 'delete'
    })
}

/**
 * 批量删除
 * @param id
 * @returns {*}
 */
export function batchDeleteUmsPermission (parameter) {
    return axios({
        url: api.umsPermissionUrl + 'delete/batch',
        method: 'post',
        data: parameter
    })
}

/**
 * 异步获取权限树
 * /admin/tree/{parentId}
 * @param parentId
 * @returns {*}
 */
export function getPermissionTreeChildren (parentId) {
  return axios({
    url: api.umsPermissionUrl + 'admin/tree/' + parentId,
    method: 'get'
  })
}
